package com.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.entity.MusicListType;
import com.service.MusicListTypeService;

@RequestMapping("/musicListType")
@Controller
public class MusicListTypeController {

	@Autowired
	private MusicListTypeService musicListTypeService;
	
	@RequestMapping("/musicListType_show")
	public String musicListType_show(Model model) {
		List<Map<String, Object>> musicListTypeList = musicListTypeService.queryMusicListType();
		model.addAttribute("musicListTypeList", musicListTypeList);
		return "admin/musicListType";
	}
	
	@RequestMapping("/musicListType_add_show")
	public String musicListType_add_show() {
		return "admin/musicListType-add";
	}
	
	@RequestMapping("/musicListType_add_submit")
	public String musicListType_add_submit(MusicListType musicListType) {
		musicListTypeService.addMusicListType(musicListType);
		return "admin/musicListType-add";
	}
	
	@RequestMapping("/musicListType_update_show")
	public String musicListType_update_show(Integer musicListTypeId,Model model) {
		Map<String, Object> musicListTypeMap = musicListTypeService.queryMusicListTypeId(musicListTypeId);
		model.addAttribute("musicListTypeMap", musicListTypeMap);
		return "admin/musicListType-edit";
	}
	
	@RequestMapping("/musicListType_update_submit")
	public String musicListType_update_submit(MusicListType musicListType) {
		musicListTypeService.editMusicListType(musicListType);
		return "admin/musicListType-edit";
	}
	
	@RequestMapping("/musicListType_delete")
	public String musicListType_delete(Integer musicListTypeId) {
		musicListTypeService.del(musicListTypeId);
		return "admin/musicListType";
	}
}
